import ACT from '../actionType'

//初始值
export const initState = {
  courseList: {
    page: 1,
    pageSize: 10,
    sort: {},
    filter: {}
  }
}
export const reduce = {
  [ACT.COURSE_COURSELIST_GET]: (state, { type, payload, meta }) => {
    console.log('payload', payload)
    return {
      ...state,
      courseList: {
        ...payload.data,
        page: meta.page,
        pageSize: meta.pageSize
      }
    }
  }
}

export default { reduce, initState }

// function reducer(state = initState, { type, payload, meta }) {
//   let { data, code, message, success } = payload || {}
//   switch (type) {
//     case ACT.COURSE_COURSELIST_GET:
//       console.log('data', data)
//       return {
//         ...state,
//         courseList: {
//           ...data,
//           page: meta.page,
//           pageSize: meta.pageSize
//         }
//       }
//     default:
//       return state
//   }
// }
